/**
 * 
 */
package fpt.pits.blo;

import java.util.List;

import fpt.pits.dao.ApplicationInfoDAO;
import fpt.pits.dao.CompanyInfoDAO;
import fpt.pits.dao.CourseApplicationInfoDAO;
import fpt.pits.dao.CourseDatabaseInfoDAO;
import fpt.pits.dao.CourseExpInfoDAO;
import fpt.pits.dao.CourseFrameworkInfoDAO;
import fpt.pits.dao.CourseInfoDAO;
import fpt.pits.dao.CourseLanguageInfoDAO;
import fpt.pits.dao.CourseTechnologyInfoDAO;
import fpt.pits.dao.DatabaseInfoDAO;
import fpt.pits.dao.DepartExpInfoDAO;
import fpt.pits.dao.DepartmentInfoDAO;
import fpt.pits.dao.EmployeeInfoDAO;
import fpt.pits.dao.FrameworkInfoDAO;
import fpt.pits.dao.LanguageInfoDAO;
import fpt.pits.dao.ProjectApplicationInfoDAO;
import fpt.pits.dao.ProjectDatabaseInfoDAO;
import fpt.pits.dao.ProjectExpInfoDAO;
import fpt.pits.dao.ProjectFrameworkInfoDAO;
import fpt.pits.dao.ProjectInfoDAO;
import fpt.pits.dao.ProjectLanguageInfoDAO;
import fpt.pits.dao.ProjectTechnologyInfoDAO;
import fpt.pits.dao.TechnologyInfoDAO;
import fpt.pits.dto.ApplicationInfo;
import fpt.pits.dto.CompanyInfo;
import fpt.pits.dto.CourseApplicationInfo;
import fpt.pits.dto.CourseDatabaseInfo;
import fpt.pits.dto.CourseExpInfo;
import fpt.pits.dto.CourseFrameworkInfo;
import fpt.pits.dto.CourseInfo;
import fpt.pits.dto.CourseLanguageInfo;
import fpt.pits.dto.CourseTechnologyInfo;
import fpt.pits.dto.DatabaseInfo;
import fpt.pits.dto.DepartExpInfo;
import fpt.pits.dto.DepartmentInfo;
import fpt.pits.dto.EmployeeInfo;
import fpt.pits.dto.FrameworkInfo;
import fpt.pits.dto.LanguageInfo;
import fpt.pits.dto.ProjectApplicationInfo;
import fpt.pits.dto.ProjectDatabaseInfo;
import fpt.pits.dto.ProjectExpInfo;
import fpt.pits.dto.ProjectFrameworkInfo;
import fpt.pits.dto.ProjectInfo;
import fpt.pits.dto.ProjectLanguageInfo;
import fpt.pits.dto.ProjectTechnologyInfo;
import fpt.pits.dto.TechnologyInfo;

/**
 * @author yoyosakura
 *
 */
public class EmployeeInfoBLO {
    private EmployeeInfoDAO employeeDAO = new EmployeeInfoDAO();
    private CourseExpInfoDAO ceDAO = new CourseExpInfoDAO();
    private DepartExpInfoDAO deDAO = new DepartExpInfoDAO();
    private ProjectExpInfoDAO peDAO = new ProjectExpInfoDAO();
    private CourseInfoDAO courseDAO = new CourseInfoDAO();
    private DepartmentInfoDAO departmentDAO = new DepartmentInfoDAO();
    private ProjectInfoDAO projectDAO = new ProjectInfoDAO();
    private CourseApplicationInfoDAO caDAO = new CourseApplicationInfoDAO();
    private CourseDatabaseInfoDAO cdDAO = new CourseDatabaseInfoDAO();
    private CourseFrameworkInfoDAO cfDAO = new CourseFrameworkInfoDAO();
    private CourseLanguageInfoDAO clDAO = new CourseLanguageInfoDAO();
    private CourseTechnologyInfoDAO ctDAO = new CourseTechnologyInfoDAO();
    private CompanyInfoDAO companyDAO = new CompanyInfoDAO();
    private ProjectApplicationInfoDAO paDAO = new ProjectApplicationInfoDAO();
    private ProjectDatabaseInfoDAO pdDAO = new ProjectDatabaseInfoDAO();
    private ProjectFrameworkInfoDAO pfDAO = new ProjectFrameworkInfoDAO();
    private ProjectLanguageInfoDAO plDAO = new ProjectLanguageInfoDAO();
    private ProjectTechnologyInfoDAO ptDAO = new ProjectTechnologyInfoDAO();
    private ApplicationInfoDAO applicationDAO = new ApplicationInfoDAO();
    private DatabaseInfoDAO databaseDAO = new DatabaseInfoDAO();
    private FrameworkInfoDAO frameworkDAO = new FrameworkInfoDAO();
    private LanguageInfoDAO languageDAO = new LanguageInfoDAO();
    private TechnologyInfoDAO technologyDAO = new TechnologyInfoDAO();
    
    public EmployeeInfo get(int empID) {
        EmployeeInfo employee = null;
        int i;
        int j;
        
        List<CourseExpInfo> ceList = ceDAO.getByEmpID(empID);
        for (i = 0; i < ceList.size(); i++) {
            CourseExpInfo ceInfo = ceList.get(i);
            CourseInfo courseInfo = courseDAO.get(ceInfo.getCourseID());
            List<CourseApplicationInfo> caList = caDAO.getByCourseID(courseInfo.getCourseID());
            for (j = 0; j < caList.size(); j++) {
                CourseApplicationInfo caInfo = caList.get(j);
                ApplicationInfo applicationInfo = applicationDAO.getByCoureID(caInfo.getCourseID());
                caList.get(j).setApplication(applicationInfo);
            }
            List<CourseDatabaseInfo> cdList = cdDAO.getByCourseID(courseInfo.getCourseID());
            for (j = 0; j < cdList.size(); j++) {
                CourseDatabaseInfo cdInfo = cdList.get(j);
                DatabaseInfo databaseInfo = databaseDAO.getByCoureID(cdInfo.getCourseID());
                cdList.get(j).setDatabase(databaseInfo);
            }
            List<CourseFrameworkInfo> cfList = cfDAO.getByCourseID(courseInfo.getCourseID());
            for (j = 0; j < cfList.size(); j++) {
                CourseFrameworkInfo cfInfo = cfList.get(j);
                FrameworkInfo frameworkInfo = frameworkDAO.getByCoureID(cfInfo.getCourseID());
                cfList.get(j).setFramework(frameworkInfo);
            }
            List<CourseLanguageInfo> clList = clDAO.getByCourseID(courseInfo.getCourseID());
            for (j = 0; j < clList.size(); j++) {
                CourseLanguageInfo clInfo = clList.get(j);
                LanguageInfo languageInfo = languageDAO.getByCoureID(clInfo.getCourseID());
                clList.get(j).setLanguage(languageInfo);
            }
            List<CourseTechnologyInfo> ctList = ctDAO.getByCourseID(courseInfo.getCourseID());
            for (j = 0; j < ctList.size(); j++) {
                CourseTechnologyInfo ctInfo = ctList.get(j);
                TechnologyInfo technologyInfo = technologyDAO.getByCoureID(ctInfo.getCourseID());
                ctList.get(j).setTechnology(technologyInfo);
            }
            DepartmentInfo deparmentInfo = departmentDAO.get(courseInfo.getDepartID());
            courseInfo.setCaList(caList);
            courseInfo.setCdList(cdList);
            courseInfo.setCfList(cfList);
            courseInfo.setClList(clList);
            courseInfo.setCtList(ctList);
            courseInfo.setDepartment(deparmentInfo);
            ceList.get(i).setCourse(courseInfo);
        }
        
        List<DepartExpInfo> deList = deDAO.getByEmpID(empID);
        for (i = 0; i < deList.size(); i++) {
            DepartExpInfo deInfo = deList.get(i);
            DepartmentInfo departmentInfo = departmentDAO.get(deInfo.getDepartID());
            CompanyInfo companyInfo = companyDAO.get(departmentInfo.getCompanyID());
            departmentInfo.setCompany(companyInfo);
            deList.get(i).setDepartment(departmentInfo);
        }
        
        List<ProjectExpInfo> peList = peDAO.getByEmpID(empID);
        for (i = 0; i < peList.size(); i++) {
            ProjectExpInfo peInfo = peList.get(i);
            ProjectInfo projectInfo = projectDAO.get(peInfo.getProjectID());
            List<ProjectApplicationInfo> paList = paDAO.getByProjectID(projectInfo.getProjectID());
            for (j = 0; j < paList.size(); j++) {
                ProjectApplicationInfo caInfo = paList.get(j);
                ApplicationInfo applicationInfo = applicationDAO.getByCoureID(caInfo.getProjectID());
                paList.get(j).setApplication(applicationInfo);
            }
            List<ProjectDatabaseInfo> pdList = pdDAO.getByProjectID(projectInfo.getProjectID());
            for (j = 0; j < pdList.size(); j++) {
                ProjectDatabaseInfo cdInfo = pdList.get(j);
                DatabaseInfo databaseInfo = databaseDAO.getByCoureID(cdInfo.getProjectID());
                pdList.get(j).setDatabase(databaseInfo);
            }
            List<ProjectFrameworkInfo> pfList = pfDAO.getByProjectID(projectInfo.getProjectID());
            for (j = 0; j < pfList.size(); j++) {
                ProjectFrameworkInfo cfInfo = pfList.get(j);
                FrameworkInfo frameworkInfo = frameworkDAO.getByCoureID(cfInfo.getProjectID());
                pfList.get(j).setFramework(frameworkInfo);
            }
            List<ProjectLanguageInfo> plList = plDAO.getByProjectID(projectInfo.getProjectID());
            for (j = 0; j < plList.size(); j++) {
                ProjectLanguageInfo clInfo = plList.get(j);
                LanguageInfo languageInfo = languageDAO.getByCoureID(clInfo.getProjectID());
                plList.get(j).setLanguage(languageInfo);
            }
            List<ProjectTechnologyInfo> ptList = ptDAO.getByProjectID(projectInfo.getProjectID());
            for (j = 0; j < ptList.size(); j++) {
                ProjectTechnologyInfo ctInfo = ptList.get(j);
                TechnologyInfo technologyInfo = technologyDAO.getByCoureID(ctInfo.getProjectID());
                ptList.get(j).setTechnology(technologyInfo);
            }
            DepartmentInfo departmentInfo = departmentDAO.get(projectInfo.getDepartID());
            projectInfo.setPaList(paList);
            projectInfo.setPdList(pdList);
            projectInfo.setPfList(pfList);
            projectInfo.setPlList(plList);
            projectInfo.setPtList(ptList);
            projectInfo.setDepartment(departmentInfo);
            peList.get(i).setProject(projectInfo);
        }
        
        employee = employeeDAO.get(empID);
        employee.setCeList(ceList);
        employee.setDeList(deList);
        employee.setPeList(peList);
        
        return employee;
    }
}
